import request from "@/utils/request";
import type {
  GetHospitalListResponse,
  GetHospitalListParams,
  GetHospitalDetailResponse,
  DepartmentList,
  GetHospitalScheduleRuleResponse,
  GetHospitalScheduleRuleParams,
  GetHospitalDoctorListParams,
  DoctorList,
} from "./types";

enum ApiPath {
  GetHospitalList = "/admin/hosp/hospital",
  GetHospitalDetail = "/admin/hosp/hospital/show",
  GetHospitalDepartmentList = "/admin/hosp/department",
  GetHospitalScheduleRule = "/admin/hosp/schedule/getScheduleRule",
  GetHospitalDoctorList = "/admin/hosp/schedule/findScheduleList",
}

// 获取医院列表
export const reqGetHospitalList = ({
  page,
  limit,
  ...params
}: GetHospitalListParams) => {
  return request.get<any, GetHospitalListResponse>(
    ApiPath.GetHospitalList + `/${page}/${limit}`,
    {
      params,
    }
  );
};

// 获取医院详情
export const reqGetHospitalDetail = (id: string) => {
  return request.get<any, GetHospitalDetailResponse>(
    ApiPath.GetHospitalDetail + `/${id}`
  );
};

// 获取医院科室列表
export const reqGetHospitalDepartmentList = (hoscode: string) => {
  return request.get<any, DepartmentList>(
    ApiPath.GetHospitalDepartmentList + `/${hoscode}`
  );
};

// 获取医院排班规则
export const reqGetHospitalScheduleRule = ({
  page,
  limit,
  hoscode,
  depcode,
}: GetHospitalScheduleRuleParams) => {
  return request.get<any, GetHospitalScheduleRuleResponse>(
    ApiPath.GetHospitalScheduleRule + `/${page}/${limit}/${hoscode}/${depcode}`
  );
};

// 获取医院医生列表
export const reqGetHospitalDoctorList = ({
  hoscode,
  depcode,
  workDate,
}: GetHospitalDoctorListParams) => {
  return request.get<any, DoctorList>(
    ApiPath.GetHospitalDoctorList + `/${hoscode}/${depcode}/${workDate}`
  );
};
